package cn.com.db.service;

import cn.com.db.model.Deck;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DeckService extends BaseService {

    public Boolean isExist(String id){
        if (StringUtils.isBlank(id)){
            return false;
        }
        return getDeckById(id)!=null;
    }

    public Deck getDeckById(String id){
        return deckDao.getDeckById(id);
    }

    public void createDeck(Deck deck){
        deckDao.createDeck(deck);
    }

    public List<Deck> getDeck(String parent){
        return deckDao.getDeck(parent);
    }

    public Integer countDeck(String parent){
        return deckDao.countDeck(parent);
    }

    @Transactional
    public void updateDeck(Deck deck){
        deckDao.update(deck);
    }


}
